package com.java.servlet;

import com.sun.jdi.Value;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author: wjr
 * @Description: 退出登录Servlet
 * @Date Created in  2020-09-03 12:30
 * @Modified By:
 */
@WebServlet(value = "/loginOut")
public class LoginOutServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        HttpSession session = req.getSession();
        //销毁名为user的session信息
        session.removeAttribute("user");
        //重定向到登录界面
        resp.sendRedirect("index.jsp");
    }
}
